/****************************************
Figure A.14
*****************************************/

import delimited "$dir/Data/Final/WB_gdp_country.csv", clear 

* Reformat GDP/Capital data
drop in 1/3
rename v1 Country
rename v2 CountryCode
rename v58 gdp_per_capita
keep Country* gdp*

replace Country = "Czech Republic" if CountryCode == "CZE"
replace Country = "Egypt" if CountryCode == "EGY"
replace Country = "Iran" if CountryCode == "IRN"
replace Country = "Kyrgyzstan" if CountryCode == "KGZ"
replace Country = "Syria" if CountryCode == "SYR"
replace Country = "Turkey" if CountryCode == "TUR"
replace Country = "Venezuela" if CountryCode == "VEN"
replace Country = "Yemen" if CountryCode == "YEM"

tempfile data_gdp
save `data_gdp'

import excel "$dir/Data/Final/consang_marriage.xlsx", sheet("Sheet1") firstrow clear

merge 1:1 Country using "`data_gdp'"
keep if _merge == 3
drop _merge

gen consang = ConsangMarriagePct / 100

label var consang  "Percent of marriages that are between first or second cousins (log scale)"
label var gdp_per_capita "GDP per capita"

scatter gdp consang, mlabel(Country) legend(off) ytitle("GDP per capita (log scale)") ///
	yscale(log) xscale(log) c(. l) ms(Oh none) sort ///
	ylabel(, format(%9.0gc)) ///
	xlabel(0.01 "1%" 0.02 "2%" 0.05 "5%" 0.1 "10%" 0.2 "20%" 0.4 "40%" 0.8 "80%") ylabel(2500 5000 10000 20000 40000 80000)
graph export "$dir/Output/TablesFigures/xcountry_consang_gdp_scatter.png", replace



